#!/bin/sh

if [ "$1" == "--help" ] ; then
	echo
	echo " ------------------------------------------------------------------------------"
	echo "  format: sh $0 <programs> [--force]"
	echo " ------------------------------------------------------------------------------"
	echo "  programs"
	echo "      - squid/trafficserver/varnish"
	echo "  --force"
	echo "      - for re-install"
	echo
	exit;
fi

echo
echo "- For help, type '$0 --help'"

if [ "$#" == 0 ] ; then
	echo "- No argument supplied."
	echo
	exit
fi

if [ "${2}" == "--force" ] || [ "${2}" == "-y" ] ; then
	type="reinstall"
else
	type="install"
fi

. /script/counter-start.inc

if [ -f /script/custom.webcache.inc ] ; then
	. /script/custom.webcache.inc
else
	. /script/webcache.inc
fi

webcache_select="webcache_${1}"

if [ -z "${webcache_select}" ] ; then
	yum ${type} ${webcache_select} -y
	
	chkconfig ${webcache_select} off
	service ${webcache_select} stop
else
	echo "- Input not match"
	echo
	exit
fi

. /script/counter-end.inc

echo

